layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 管理
     */
    var Indent = {
        tableId: "indentListTable"
    };

    /**
     * 初始化表格的列
     */
    Indent.initColumn = function () {
        return [[
            {type: 'checkbox'},
            {field: 'id', hide: true, title: '主键'},
            {field: 'productName', hide: false, title: '产品'},
            {field: 'productModelName', sort: true, title: '产品型号'},
            {field: 'productOrderName', sort: true, title: '产品编号'},
            {field: 'color', sort: true, title: '产品颜色'},
            {field: 'colorNumber', sort: true, title: '产品色号'},
            {field: 'material', sort: true, title: '产品材质'},
            {field: 'price', sort: true, title: '价格'},
            {field: 'unitVolume', sort: true, title: '单台体积'},
            {field: 'unitWeight', sort: true, title: '单台净重'},
            /*{field: 'channelStr', sort: true, title: '渠道'},*/
            {field: 'orderNumbers',sort:true,title:'购买数量'},
            {field: 'orderAmount',sort:true,title:'总金额'},
            {field: 'havaSend',sort:true,title:'已发数量'},
            {field: 'notSend',sort:true,title:'未发数量'}
        ]];
    };

    /**
     * 点击查询按钮
     */
    Indent.search = function () {
        var queryData = {};
        queryData['condition'] = $("#condition").val();
        table.reload(Indent.tableId, {where: queryData});
    };



    $("#getProductList").click(function () {
        var checkStatus = table.checkStatus('indentListTable'),
            data = checkStatus.data;
        for (var i = 0; i < data.length; i++) {
            data[i].type = "请选择售后类型";
            data[i].type = "";
            data[i].reason = "请输入售后原因";
        }
        admin.putTempData("product_list", data);
        admin.closeThisDialog();
        // layer.alert(JSON.stringify(data));
    });

    console.log("传过来的id是："+$("#id").val());
    // 渲染表格
    var tableResult = table.render({
        elem: '#' + Indent.tableId,
        url: Feng.ctxPath + '/purchaseOrders/getIndentOrderByDealer/'+ $("#id").val(),
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        cols: Indent.initColumn()
    });


    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        Indent.search();
    });




});
